<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<jsp:include page="../frame/header.jsp"></jsp:include>

<title>频道信息列表</title>
</head>

<body>

	<div class="container-fluid">
		<div id="market" class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">电台系统</a> <span class="divider">/</span></li>
					<li><a href="#">频道管理</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						<i class="icon-th"></i> 频道信息列表
					</h2>

					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<div id="search-form">
						<form id="searchForm" method="post" class="form-search span12" action="<c:url value="/admin/radio/search_radioChannel"/>">
							类型
							<select id="cType" class="input-small" name="cType">
								<option value="0">全部</option>
								<c:forEach var="sort" items="${cTypes }">
									<option value="${sort.tagId }" <c:if test="${sort.tagId == searchForm.cType }">selected</c:if> >${sort.tagName }</option>
								</c:forEach>
							</select>
							风格
							<select id="cStyle" class="input-small" name="cStyle">
								<option value="0">全部</option>
								<c:forEach var="sort" items="${cStyles }">
									<option value="${sort.tagId }" <c:if test="${sort.tagId == searchForm.cStyle }">selected</c:if> >${sort.tagName }</option>
								</c:forEach>
							</select>
							场景
							<select id="cScene" class="input-small" name="cScene">
								<option value="0">全部</option>
								<c:forEach var="sort" items="${cScenes }">
									<option value="${sort.tagId }" <c:if test="${sort.tagId == searchForm.cScene }">selected</c:if> >${sort.tagName }</option>
								</c:forEach>
							</select>
							
							<input type="hidden" name="pageNum" id="pageNum" value="${searchForm.pageNum }">
							<input type="hidden" name="infoId" id="infoId" value="${searchForm.infoId }">
							<input type="text" name="search" id="searchText" value="${searchForm.search }" 
								class="search-query">
							<button type="button" id="searchBtn" class="btn">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
							<button type="button" id="newBtn" class="btn btn-danger pull-right">添加频道信息</button>
						</form>
						
					</div>
					<table id="userInfo" class="table table-striped table-bordered ">
						<thead>
							<tr>
								<th>专辑号</th>
								<th>专辑名称</th>
								<th>类型</th>
								<th>风格</th>
								<th>场景</th>
								<th>节目数</th>
								<th>创建时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="info" items="${pageModel.result }" varStatus="status">
								<tr>
									<td>${info.channelNum }</td>
									<td>${info.channelName } </td>
									<td>${info.cTypeName }</td>
									<td>${info.cStyleName }</td>
									<td>${info.cSceneName }</td>
									<td>${info.programs }</td>
									<td>${info.createDate }</td>
									<td><a href="javascript:edit('${info.channelId }')"><i
											class="icon-edit"></i></a> &nbsp;&nbsp; <a
										href="javascript:del('${info.channelId }')"><i class="icon-minus"></i></a></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					
					<div id="mypager" class="mypager"></div>
				</div>
			</div>
		</div>
		<!--/fluid-row-->

	</div>
	<!--/.fluid-container-->

	<jsp:include page="../frame/scripts.jsp"></jsp:include>
	<script type="text/javascript">
	var pageNum = "${pageModel.pageNum}";
	var totalPage = "${pageModel.totalPage}";
	var numPerPage = "${pageModel.numPerPage}";
	
	$(document).ready(function(){
		
		$("#newBtn").click(function(){
			//跳转至新增页面
			window.location.href = '<c:url value="/admin/radio/addChannel" />';
		})
		
		$('#mypager').bootstrapPaginator({
			currentPage:pageNum,
			totalPages:totalPage,
			numberOfPages:numPerPage,
			onPageClicked:function(event, originalEvent, type,page){
				$("input[name='pageNum']").val(page);
				$("#searchForm").submit();
			}
		});
		
		$('#cType,#cScene,#cStyle').change(function(){
			$("#searchForm").submit();
		})
		
		$('#searchBtn').click(function(){
			$("#searchForm").submit();
		})
	})
	
	function edit(infoId){
		window.location.href = '<c:url value="/admin/radio/editChannel?infoId='+infoId+'"/>';
	}
	
	function del(infoId){
		if(confirm("确定要删除吗？")){
			$("input[name='infoId']").val(infoId);
			$("#searchForm").submit();
		}
	}
	
	
	</script>
</body>
</html>
